<template>
	<div class="body-layout">
		<!-- 详情 -->
		<div class="wb-detail vf-detail">
			<div class="top-header">
				<!-- 返回按钮 -->
				<a  class="header-left"></a>
				<article class="header-middle" v-if="previewInfoFanl">
					<img src="../../assets/images/icon-v.png" /> {{previewInfoFanl.userNickName}}
				</article>
				<article class="header-right">
					<section class="header-right_icon">
						<div class="header-info_btn">
							<a href="javascript:;"><i></i>关注</a>
						</div>
					</section>
				</article>
			</div>
			<div class="title" v-if="previewInfoFanl">{{previewInfoFanl.title}}</div>
			<div class="detail-tools">
				<span class="detail-tools_time" v-if="previewInfoFanl">{{time}}</span>
				<span class="detail-tools_view">阅读</span><span class="detail-tools_view">{{randomNum}}</span>
			</div>
			<div class="share">
				<span>分享到</span>
				<ul>
					<li><img src="../../assets/images/1.png" /></li>
					<li><img src="../../assets/images/2.png" /></li>
					<li><img src="../../assets/images/3.png" /></li>
					<li><img src="../../assets/images/icon-qq.png" /></li>
				</ul>
			</div>
			<div class="detail-content" v-if="previewInfoFanl">
				<div class="ql-editor preview-content" v-html="previewInfoFanl.content"></div>
			</div>
		</div>
	</div>
</template>

<script>
  import {mapState, mapActions} from 'vuex';
  import util from '@/lib/util';
	export default {
    name: 'wb',
    data() {
      return {
        view_id: '',
        previewInfoFanl: {},
        time: null
      }
    },
    computed: {
      ...mapState([
        'articleDetail' //当前文章对象
      ]),
      randomNum () {
        let num = parseInt(Math.random()*10000)
        return num
      }
    },
    methods: {
      getPreviewDetail() {
        let param = {
          id: this.view_id
        }
        util.ajax.post(`/article/preview/detail`,{...param}).then((res) => {
          // 获取预览观点详情
          this.previewInfoFanl = res.data;
          this.time = util.formatTime(this.previewInfoFanl.createTime)
        });
      }
    },
    created() {
      // 获取观点详情
      this.view_id = this.$route.query.id || this.articleDetail.articleId;
      if (this.view_id) {

        this.getPreviewDetail();

      }
    }
	}
</script>

<style scoped lang="scss">
	@import "@/assets/css/style.scss";
	.wb-detail {
		width: 92%;
		margin: 0 auto;
		padding-top: 48px;
		.banner {
			margin: 0px 0px 11px;
			width: 100%;
			height: 212px;
			line-height: 212px;
			text-align: center;
			img {
				width: 100%;
				height: 100%;
			}
		}
		.title {
			margin-bottom: 7px;
			font-size: 24px;
			color: #333333;
			letter-spacing: 0;
			line-height: 30px;
		}
		.detail-tools {
			margin-bottom: 16px;
			font-size: 14px;
			color: #959595;
			line-height: 20px;
			&_view {
				margin-right: 5px;
				font-size: 13px;
			}
		}
		.share {
			margin-bottom: 62px;
			width: 100%;
			font-size: 14px;
			color: #959595;
			line-height: 28px;
			overflow: hidden;
			span {
				float: left;
				display: inline-block;
				width: 24%;
			}
			ul {
				float: right;
				width: 76%;
				li {
					float: left;
					width: 25%;
					text-align: center;
					img {
						width: 29px;
						height: 29px;
					}
				}
			}
		}
		.detail-content {
			padding-bottom: 60px;
			p {
				font-size: 18px;
				color: #333333;
				line-height: 29px;
			}
			.img-box {
				width: 100%;
				height: 212px;
				line-height: 212px;
				text-align: center;
				img {
					max-width: 100%;
					height: auto !important;
				}
			}
		}
	}
</style>
